package com.ht.jooq.util.converter;

import org.jooq.Converter;

import java.sql.Timestamp;
import java.util.Date;

/**
 * Created by bcw on 14-4-4.
 */
public class DateConverter implements Converter<Timestamp, Date> {
    @Override
    public Date from(Timestamp databaseObject) {
        return databaseObject == null ? null : new Date(databaseObject.getTime());
    }

    @Override
    public Timestamp to(Date userObject) {
        return userObject == null ? null : new Timestamp(userObject.getTime());
    }

    @Override
    public Class<Timestamp> fromType() {
        return Timestamp.class;
    }

    @Override
    public Class<Date> toType() {
        return Date.class;
    }
}
